﻿using d1Common;
using d1Project.Modules.Common.do4A.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace d1Project.Modules.Common.do4A.Domain
{
    public class AuditLogMgr
    {
        private static AuditLogMgr singleInstance = new AuditLogMgr();
        public static AuditLogMgr Instance
        {
            get
            {
                return singleInstance;
            }
        }

        public void WriteAuditLog(string _TypeId, string _TypeName, string _userId, string _userName, string _desc)
        {
            do4ADbContext db = new do4ADbContext();
            try
            {
                AuditLog _auditLog = new Models.AuditLog();
                _auditLog.Id = doServices.Instance.DoCore.getGUID();
                _auditLog.TypeId = _TypeId;
                _auditLog.TypeName = _TypeName;
                _auditLog.UserId = _userId;
                _auditLog.UserName = _userName;
                _auditLog.CreateTime = DateTime.Now;
                _auditLog.Desc = _desc;
                db.AuditLogs.Add(_auditLog);
                db.SaveChanges();
            }
            finally
            {
                db.Dispose();
            }

        }
    }
}